package com.ruoyi.examination.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.examination.util.SnowflakeIdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.examination.mapper.AnswerRecordMapper;
import com.ruoyi.examination.domain.AnswerRecord;
import com.ruoyi.examination.service.IAnswerRecordService;

/**
 * 答题记录Service业务层处理
 * 
 * @author hcc
 * @date 2025-10-21
 */
@Service
public class AnswerRecordServiceImpl implements IAnswerRecordService 
{
    @Autowired
    private AnswerRecordMapper answerRecordMapper;

    /**
     * 查询答题记录
     * 
     * @param answerRecordId 答题记录主键
     * @return 答题记录
     */
    @Override
    public AnswerRecord selectAnswerRecordByAnswerRecordId(String answerRecordId)
    {
        return answerRecordMapper.selectAnswerRecordByAnswerRecordId(answerRecordId);
    }

    /**
     * 查询答题记录列表
     * 
     * @param answerRecord 答题记录
     * @return 答题记录
     */
    @Override
    public List<AnswerRecord> selectAnswerRecordList(AnswerRecord answerRecord)
    {
        return answerRecordMapper.selectAnswerRecordList(answerRecord);
    }

    /**
     * 新增答题记录
     * 
     * @param answerRecord 答题记录
     * @return 结果
     */
    @Override
    public int insertAnswerRecord(AnswerRecord answerRecord)
    {
        answerRecord.setAnswerRecordId(String.valueOf(new SnowflakeIdUtils(5,8).nextId()));
        answerRecord.setCreateTime(DateUtils.getNowDate());
        answerRecord.setCreateBy(SecurityUtils.getUsername());
        return answerRecordMapper.insertAnswerRecord(answerRecord);
    }

    /**
     * 修改答题记录
     * 
     * @param answerRecord 答题记录
     * @return 结果
     */
    @Override
    public int updateAnswerRecord(AnswerRecord answerRecord)
    {
        answerRecord.setUpdateTime(DateUtils.getNowDate());
        return answerRecordMapper.updateAnswerRecord(answerRecord);
    }

    /**
     * 批量删除答题记录
     * 
     * @param answerRecordIds 需要删除的答题记录主键
     * @return 结果
     */
    @Override
    public int deleteAnswerRecordByAnswerRecordIds(String[] answerRecordIds)
    {
        return answerRecordMapper.deleteAnswerRecordByAnswerRecordIds(answerRecordIds);
    }

    /**
     * 删除答题记录信息
     * 
     * @param answerRecordId 答题记录主键
     * @return 结果
     */
    @Override
    public int deleteAnswerRecordByAnswerRecordId(String answerRecordId)
    {
        return answerRecordMapper.deleteAnswerRecordByAnswerRecordId(answerRecordId);
    }
}
